/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uit_vendor_management;

/**
 *
 * @author QuangKhoi
 */
public class District {
    public String MaQuan;
    public String TenQuan;
    public Integer SoDaiLyDoiDa;
    
    public District() {
        QueryResult result = Database.instance.Query("SELECT * FROM QUAN");
        if (result.Count > 0) {
            this.MaQuan = result.Table.getString(0, 0);
            this.TenQuan = result.Table.getString(0, 1);
            this.SoDaiLyDoiDa = result.Table.getInteger(0, 2);
        }
    }
    
    public District(String MaQuan) {
        QueryResult result = Database.instance.Query("SELECT * FROM QUAN "
                + "WHERE MaQuan='" + MaQuan + "'");
        if (result.Count > 0) {
            this.MaQuan = result.Table.getString(0, 0);
            this.TenQuan = result.Table.getString(0, 1);
            this.SoDaiLyDoiDa = result.Table.getInteger(0, 2);
        }
    }
    
    public static javax.swing.DefaultComboBoxModel getModel() {
        QueryResult result = Database.instance
                .Query("SELECT MaQuan, TenQuan FROM QUAN");
        String[] model = new String[result.Count];
        for (int i = 0; i < result.Count; i++) {
            model[i] = result.Table.getString(i, 1);
        }
        return new javax.swing.DefaultComboBoxModel(model);
    }
}
